<template>
  <div>
    <div class="top">
      TODOLIST {{user.name}}
      <el-button @click="logout">退出登录</el-button>
      {{getuserdata}}
    </div>
    <List></List>
  </div>
</template>
<script setup>
  import { ElButton } from 'element-plus'
  import List from '@/components/List.vue'
</script>
<script >
import { removeLocal } from '@/utils/tool'
import { getUsers,loginOut } from '@/api/user'
export default {
  data() {
    return {
      getuserdata:''
    }
  },
  created(){
    console.log(import.meta.env)
    console.log(import.meta.env.MODE)
    getUsers().then(res=>{
      console.log(res)
      this.getuserdata = res.data[0]
    })
  },
  methods: {
    logout(){
      loginOut().then(res=>{
        if(res.code == 200){
          removeLocal('user')
          removeLocal('token')
          this.$router.push('login')
        }
      })
    }
  },
  computed: {
    user (){
      return this.$store.getters.getUser
    }
  }
}
</script>

<style lang="scss" scoped>

</style>